﻿using Microsoft.Extensions.DependencyInjection;
using Modules.BankSpecialAccount.Entitys;
using Modules.BankSpecialAccount.Repositories;
using PmSoft;

namespace Modules.BankSpecialAccount;

/// <summary>
/// 专户累计进账、线上和线下代发金额统计服务
/// </summary>
[UseDI(ServiceLifetime.Scoped)]
public class BankSpecialAccountStatisticService
{
    private readonly BankSpecialAccountStatisticRepository projectSpecialAccountStatisticRepository;

    public BankSpecialAccountStatisticService(BankSpecialAccountStatisticRepository projectSpecialAccountStatisticRepository)
    {
        this.projectSpecialAccountStatisticRepository = projectSpecialAccountStatisticRepository;
    }

    /// <summary>
    /// 专户累计进账、线上和线下代发金额统计表单详情
    /// </summary>
    /// <param name="id">主键</param>
    /// <returns></returns>
    public BankSpecialAccountStatistic? Get(int id)
    {
        return projectSpecialAccountStatisticRepository.Get(id);
    }

    /// <summary>
    /// 批量删除，根据id
    /// </summary>
    /// <param name="ids">id的集合</param>
    public void Deleted(IEnumerable<int> ids)
    {
        foreach (int id in ids)
        {
            Delete(id);
        }
    }

    /// <summary>
    /// 单个删除
    /// </summary>
    /// <param name="id">主键</param>
    public void Delete(int id)
    {
        projectSpecialAccountStatisticRepository.DeleteByEntityId(id);
    }

    /// <summary>
    /// 创建专户累计进账、线上和线下代发金额统计
    /// </summary>
    /// <param name="entity">实体对象</param>
    public void Create(BankSpecialAccountStatistic entity)
    {
        projectSpecialAccountStatisticRepository.Insert(entity);
    }

    /// <summary>
    /// 编辑专户累计进账、线上和线下代发金额统计
    /// </summary>
    /// <param name="entity">实体对象</param>
    public void Update(BankSpecialAccountStatistic entity)
    {
        projectSpecialAccountStatisticRepository.Update(entity);
    }

    /// <summary>
    /// 通过银行专户账号获取统计信息
    /// </summary>
    /// <param name="account"></param>
    /// <returns></returns>
    public BankSpecialAccountStatistic? GetProjectSpecialAccountStatisticByBankAccount(string account)
    {
        return projectSpecialAccountStatisticRepository.GetProjectSpecialAccountStatisticByBankAccount(account);
    }

    /// <summary>
    /// 获取专户统计信息
    /// </summary>
    /// <param name="accounts"></param>
    /// <returns></returns>
    public IEnumerable<BankSpecialAccountStatistic> GetProjectSpecialAccountStatistics(IEnumerable<string> accounts)
    {
        return projectSpecialAccountStatisticRepository.GetProjectSpecialAccountStatistics(accounts);
    }
}